<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        function outer(){
            let someVariable = "someValue";

            return function(){
                console.log(someVariable);
            }
        }

        /* 
            闭包的生命周期：
                1. 闭包在外部函数调用时产生，外部函数每次调用都会产生一个全新的闭包
        */

        function outer2(){
            let num = 0;
            return () => {
                num++;
                console.log(num);
            }
        }

        const fn1 = outer2();

        fn1();
    </script>
</head>
<body>
    
</body>
</html>